﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using SIPO.Library.DomainObject.Administration;
using SIPO.Library.DataAccess.Administration;
using SIPO.Library.DomainObject.Transaction;
using SIPO.Library.DataAccess.Transaction;
using System.Configuration;
using SIPO.Library.DataAccess.Administration.Catalog;
using SIPO.Library.DomainObject.Administration.Catalog;

namespace SIPO.Web.Forms.Transaction
{
    public partial class recImpositionCurrentform : BasePage
    {
        private int id = -1;
        private recImpositionRepo recImpositionRepo = new recImpositionRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);
        protected override void OnLoad(EventArgs e)
        {
            if (Request.Params["id"] != null)
            {
                id = Convert.ToInt32(Request.Params["id"]);
            }

            if (!Page.IsPostBack)
            {
                recDebtorRepo recDebtorRepo = new recDebtorRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);
                this.BindYear();

                //populate dropdownlist dasar pengenaan
                recImpositionBaseRepo recImpositionBaseDal = new recImpositionBaseRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);
                List<recImpositionBase> impositionBases = recImpositionBaseDal.GetList();
                ddlImpositionBase.Items.Clear();
                impositionBases.ForEach(delegate(recImpositionBase impositionBase)
                {
                    ddlImpositionBase.Items.Add(new ListItem(impositionBase.ImpositonBaseName, impositionBase.ImpositionBaseID.ToString()));
                });
                ddlImpositionBase.Items.Insert(0, new ListItem("-- pilih dasar pengenaan --", string.Empty));

                //
                ddlSubSubSector.Items.Insert(0, new ListItem("-- pilih sub sub sektor --", string.Empty));
            }

        }

        private void BindYear()
        {
            //recImposition obj = recImpositionRepo.GetByDebtorId((int)base.DebtorID);
            //int currentTahunLapKeuYear = DateTime.Now.Year - 3;
            int currentTahunLapKeuYear = 2010;
            int nextYear = DateTime.Now.Year + 8;

            IList<string> collTahunLapKeuYears = new List<string>();
            collTahunLapKeuYears.Add("--pilih tahun--");
            for (int i = currentTahunLapKeuYear; i < nextYear; i++)
            {
                collTahunLapKeuYears.Add(i.ToString());
            }

            ddlTahunLapKeu.DataSource = collTahunLapKeuYears;
            ddlTahunLapKeu.DataBind();
        }

    }
}
